package com.sky.myshop.controller;

import com.sky.myshop.services.GoodService;
import com.sky.myshop.services.OrderService;
import com.sky.myshop.vo.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//ajax,需要编程json格式
@RestController
@RequestMapping("/shopping")
public class InitCtrl {
    @Autowired
    private GoodService goodService;
    @Autowired
    private OrderService orderService;

    @RequestMapping("/allGoods")
    public List<Goods> findAllGoods(){
        return goodService.findAll();
    }

    @RequestMapping("/single/{id}")
    public Goods findGoodsById(@PathVariable("id")Integer id){
        return goodService.findById(id);
    }
}
